package org.fnzn.access.dialect;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import org.thymeleaf.dialect.AbstractDialect;
import org.thymeleaf.processor.IProcessor;
import org.fnzn.access.process.attribute.HasPermissionAttrProcessor;
import org.fnzn.access.process.attribute.HasRoleAttrProcessor;
import org.fnzn.access.process.element.HasPermissionElementProcessor;
import org.fnzn.access.process.element.HasRoleElementProcessor;
/**
 * 自定义thymeleaf标签 实现按钮权限控制
 * @author zhaolulu
 *
 */
public class AccessDialect extends AbstractDialect{

	 private static final String PREFIX = "access";
	 private static final Set<IProcessor> processors = new HashSet<IProcessor>();

	    static {
	        processors.add(HasRoleAttrProcessor.create());
	        processors.add(HasRoleElementProcessor.create());
		
	        processors.add(HasPermissionAttrProcessor.create());
	        processors.add(HasPermissionElementProcessor.create());
	
	    }

	    public AccessDialect() {
	        super();
	    }

	    public String getPrefix() {
	        return PREFIX;
	    }

	    public boolean isLenient() {
	        return false;
	    }

	    @Override
	    public Set<IProcessor> getProcessors() {
	        return Collections.unmodifiableSet(processors);
	    }



}
